﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SBACN.WebSite.Models;
using System.Linq.Expressions;
using SBACN.WebSite.Code;

namespace SBACN.WebSite.Admin.MemberService.Education
{
    public partial class ExamShowSource : BasePage
    {
		/// <summary>
		/// 系统字典类型
		/// </summary>
		public string SystemType
		{
			get
			{
				//if (ViewState["SystemType"] == null)
				//    return "00020003";//默认值
				//else
				//    return ViewState["SystemType"].ToString();
				return this.SystemCode;
			}
			private set
			{
				ViewState["SystemType"] = this.SystemCode; ;
			}
		}

        protected void Page_Load(object sender, EventArgs e)
        {
			if (!AdminBasePage.CheckCodeRight(AdminBasePage.AdminInfo, SystemType))
			{
				AdminBasePage.RedirectWithMessage(AdminDefaultPage, "您没有访问当前页面的权限,请与系统管理员联系!");
				return;
			}

            this.HidExam.Value = Request.QueryString["EID"];
            int ExamID = Convert.ToInt32(Request.QueryString["EID"]);
            ShowList(1,ExamID);
        }

        protected void ShowList(int pageIndex , int id)
        {
            Expression<Func<TB_Score, bool>> fun = (p => p.ExamID == id);
            Expression<Func<TB_Score, int>> order = (p => p.MemberID);
			Expression<Func<TB_Score, string>> then = (p => p.Name);
            int records = 0;
            this.ScoreList.DataSource = DAL.DALHelper.Instance.GetList<TB_Score, int,string>(fun, order, false,then,true,this.Pager1.PageSize, pageIndex, out records);
            this.ScoreList.DataBind();
            this.Pager1.RecordCount = records;
            this.Pager1.InitControl();
        }

        public void BindSelectedPageIndexChanged(int pageIndex, int nextPage)
        {
            int id = Convert.ToInt32(this.HidExam.Value);
            ShowList(nextPage, id);
        }


        public string MemberSel( int id)
        {
            var result = DAL.DALHelper.Instance.GetObject<TB_Member>("ID",id);
            return result.Name;
        }
        public string ExamNameSel(int id)
        {
            var result = DAL.DALHelper.Instance.GetObject<TB_Examination>("ID", id);
            return result.Subject;
        }
    }
}